var connect = require('connect');
var app = connect();

app.use(setup(':url :method'));
app.use(hello);
app.listen(9000);

function setup(format){
  var regexp = /:(\w+)/g;  // 正则表达式的分组，括号内为property值
  return function(req,res,next){
    var str = format.replace(regexp,function(match,property){  
      console.log(match + ' ' + property); // match为匹配到的字符串，property为分组的值
      return req[property];  // 同req.method, req["method"]与req.method一个含义
    });
    console.log(str);
    next();
  }
}

function hello(req,res){
  res.setHeader("Content-Type","text/html");
  res.end(req['url']);
}
